//
//  MovieCell.m
//  结构
//
//  Created by 看着太阳吃烧饼 on 15/7/20.
//  Copyright (c) 2015年 看着太阳吃烧饼. All rights reserved.
//

#import "MovieCell.h"
#import "UIImageView+WebCache.h"
#import "StarView.h"
@implementation MovieCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setModal:(MovieModal *)modal {
    _modal = modal;
    _movieStar.average = modal.average;
    [self setNeedsLayout];//需要调用layoutSubviews
}

- (void)layoutSubviews {
    
    
    _movieTitle.text = _modal.title;
    _movieYear.text = [NSString stringWithFormat:@"年份:%@",_modal.year];
    _movieAverage.text = [NSString stringWithFormat:@"%.1f",_modal.average];
    
    NSString *imageStr = [_modal.images objectForKey:@"small"];
    [_movieImage sd_setImageWithURL:[NSURL URLWithString:imageStr]];
    
//    StarView *star = [StarView alloc] initWithFrame:
    
    //
//    UIImage *image1 = [UIImage imageNamed:@"yellow"];
//    UIImage *image2 = [UIImage imageNamed:@"gray"];
//    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 5, image1.size.width*_modal.average/2, image1.size.height)];
//    UIView *view2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 5, image2.size.width*5, image2.size.height)];
//    
//    view1.backgroundColor = [UIColor colorWithPatternImage:image1];
//    view2.backgroundColor = [UIColor colorWithPatternImage:image2];
//    
//    [_movieStar addSubview:view2];
//    [_movieStar addSubview:view1];
    
//    [_movieImage sd_setImageWithUrl:[NSURL URLWithString:imageStr]];
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
